//
//  CSMyOrderFootView.m
//  ProjectforHDX
//
//  Created by wusiping on 16/8/10.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "CSMyOrderFootView.h"

#define TOPMARGIN 5
#define LEFTEMARGIN 10
#define LABHEIGHT 24

@implementation CSMyOrderFootView

-(id)initFootViewWithIsSameTime:(NSString *) isSameTime AndRemark:(NSString *)remark AndRemark:(NSString *)takeZheTime AndLogistics:(NSDictionary *)logisticsDict AndOrderType:(NSDictionary *)OrderTypeDict{
    self=[super initWithFrame:CGRectMake(0, 0, BOUNDSWIDTH, 40)];

    self.backgroundColor = [UIColor whiteColor];
    
    
    CGFloat logisticsBottom = 0;
    
    if ([[logisticsDict objectForKey:@"logisticsInfo"] objectForKey:@"com"] != nil) {
        RZCustomLable *logisticsTitleLab = [[RZCustomLable alloc]init];
        [logisticsTitleLab setFrame:CGRectMake(LEFTEMARGIN, TOPMARGIN, self.width, LABHEIGHT)];
        logisticsTitleLab.text = [NSString stringWithFormat:@"故障件物流信息"];
        logisticsTitleLab.font = [UIFont fontWithName:@"Helvetica-Bold" size:13];
        logisticsTitleLab.textColor = [UtilCheck hexStringToColor:@"858e99" alpha:1];
        logisticsTitleLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:logisticsTitleLab];
        //物流公司
        RZCustomLable *logisticsCompanyLab = [[RZCustomLable alloc]init];
        [logisticsCompanyLab setFrame:CGRectMake(LEFTEMARGIN, logisticsTitleLab.bottom, self.width, LABHEIGHT)];
        logisticsCompanyLab.text = [NSString stringWithFormat:@"物流公司:%@",[[logisticsDict objectForKey:@"logisticsInfo"]  objectForKey:@"com"]];
        logisticsCompanyLab.textColor = [UIColor blackColor];

        [logisticsCompanyLab textAttributedKey:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"物流公司:"],@"key", nil] AttributedValue:[NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionaryWithObjectsAndKeys:[UtilCheck hexStringToColor:@"999999" alpha:1],NSForegroundColorAttributeName, nil],@"key", nil]];
        logisticsCompanyLab.font = [UIFont systemFontOfSize:13];
        logisticsCompanyLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:logisticsCompanyLab];
        
        
        //运单号
        RZCustomLable *logisticsIDLab = [[RZCustomLable alloc]init];
        [logisticsIDLab setFrame:CGRectMake(LEFTEMARGIN, logisticsCompanyLab.bottom, self.width, LABHEIGHT)];
        logisticsIDLab.textColor = [UIColor blackColor];
        logisticsIDLab.text = [NSString stringWithFormat:@"运单号:%@",[[logisticsDict objectForKey:@"logisticsInfo"]  objectForKey:@"expressCode"]];
        [logisticsIDLab textAttributedKey:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"运单号:"],@"key", nil] AttributedValue:[NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionaryWithObjectsAndKeys:[UtilCheck hexStringToColor:@"999999" alpha:1],NSForegroundColorAttributeName, nil],@"key", nil]];
        logisticsIDLab.font = [UIFont systemFontOfSize:13];
        logisticsIDLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:logisticsIDLab];
        
        //分割线
        RZCustomLable *seperateLineLab = [[RZCustomLable alloc]init];
        [seperateLineLab setFrame:CGRectMake(LEFTEMARGIN, logisticsIDLab.bottom, self.width - LEFTEMARGIN*2, 0.5)];
        [seperateLineLab setBackgroundColor:[UtilCheck hexStringToColor:@"e5e5e5" alpha:1]];
        [self addSubview:seperateLineLab];
        
        logisticsBottom = seperateLineLab.bottom;
    }
    
    
    RZCustomLable *isSameTimeLab = [[RZCustomLable alloc]init];
    [isSameTimeLab setFrame:CGRectMake(LEFTEMARGIN, logisticsBottom + TOPMARGIN, BOUNDSWIDTH - LEFTEMARGIN, LABHEIGHT)];
    isSameTimeLab.text = [NSString stringWithFormat:@"%@:%@",[THMangerTool language:@"seeting.isSameTime"], isSameTime];
    isSameTimeLab.numberOfLines = 0;
    isSameTimeLab.textColor = [UIColor blackColor];
    isSameTimeLab.font = [UIFont systemFontOfSize:13];
    [isSameTimeLab textAttributedKey:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@:",[THMangerTool language:@"seeting.isSameTime"]],@"key", nil] AttributedValue:[NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionaryWithObjectsAndKeys:[UtilCheck hexStringToColor:@"999999" alpha:1],NSForegroundColorAttributeName, nil],@"key", nil]];
    
    [isSameTimeLab sizeToFit];
    [self addSubview:isSameTimeLab];
    
    if ([[OrderTypeDict objectForKey:@"type"] integerValue] == 2) {
        isSameTimeLab.hidden = YES;
        [isSameTimeLab setHeight:0.0];
    }
    
    if ([takeZheTime isEqualToString:@""]) {
        //备注
        RZCustomLable *remarkLab = [[RZCustomLable alloc]init];
        [remarkLab setFrame:CGRectMake(LEFTEMARGIN, TOPMARGIN + isSameTimeLab.bottom, BOUNDSWIDTH - LEFTEMARGIN, LABHEIGHT)];
        remarkLab.text = [NSString stringWithFormat:@"%@:%@",[THMangerTool language:@"seeting.remark"],remark];
        remarkLab.numberOfLines = 0;
        remarkLab.textColor = [UIColor blackColor];
        remarkLab.font = [UIFont systemFontOfSize:13];
        [remarkLab textAttributedKey:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@:",[THMangerTool language:@"seeting.remark"]],@"key", nil] AttributedValue:[NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionaryWithObjectsAndKeys:[UtilCheck hexStringToColor:@"999999" alpha:1],NSForegroundColorAttributeName, nil],@"key", nil]];
       
        [remarkLab sizeToFit];
        [self addSubview:remarkLab];
        [self setFrame:CGRectMake(0, 0, BOUNDSWIDTH, remarkLab.bottom + TOPMARGIN)];
    }else{
        //预计取故障件时间
        RZCustomLable *takeZheTimeLab = [[RZCustomLable alloc]init];
        [takeZheTimeLab setFrame:CGRectMake(LEFTEMARGIN, TOPMARGIN + isSameTimeLab.bottom, BOUNDSWIDTH - LEFTEMARGIN, LABHEIGHT)];
        takeZheTimeLab.text = [NSString stringWithFormat:@"%@:%@",[THMangerTool language:@"seeting.takeZheTime"],takeZheTime];
        takeZheTimeLab.numberOfLines = 0;
        takeZheTimeLab.textColor = [UIColor blackColor];
        takeZheTimeLab.font = [UIFont systemFontOfSize:13];
        [takeZheTimeLab textAttributedKey:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@:",[THMangerTool language:@"seeting.takeZheTime"]],@"key", nil] AttributedValue:[NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionaryWithObjectsAndKeys:[UtilCheck hexStringToColor:@"999999" alpha:1],NSForegroundColorAttributeName, nil],@"key", nil]];
        
        [takeZheTimeLab sizeToFit];
        [self addSubview:takeZheTimeLab];
        [self setFrame:CGRectMake(0, 0, BOUNDSWIDTH, takeZheTimeLab.bottom + TOPMARGIN)];
        
        //备注
        RZCustomLable *remarkLab = [[RZCustomLable alloc]init];
        [remarkLab setFrame:CGRectMake(LEFTEMARGIN, TOPMARGIN + takeZheTimeLab.bottom, BOUNDSWIDTH - LEFTEMARGIN, LABHEIGHT)];
        remarkLab.text = [NSString stringWithFormat:@"%@:%@",[THMangerTool language:@"seeting.remark"],remark];
        remarkLab.numberOfLines = 0;
        remarkLab.textColor = [UIColor blackColor];
        remarkLab.font = [UIFont systemFontOfSize:13];
        [remarkLab textAttributedKey:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@:",[THMangerTool language:@"seeting.remark"]],@"key", nil] AttributedValue:[NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionaryWithObjectsAndKeys:[UtilCheck hexStringToColor:@"999999" alpha:1],NSForegroundColorAttributeName, nil],@"key", nil]];
        
        [remarkLab sizeToFit];
        [self addSubview:remarkLab];
        [self setFrame:CGRectMake(0, 0, BOUNDSWIDTH, remarkLab.bottom + TOPMARGIN)];
    }
    
   


    return self;
}



@end
